﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/29/2009
 * Time: 1:08 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NUnit.Framework;
using Buaya.Model;

namespace Buaya.Tests
{
	[TestFixture]
	public class Test1
	{
		[Test]
		public void TestMethod()
		{
			Company c = null;
			if (SessionFacade.ReadCompanyByPk(1) == null) {
				c = new Company();
				c.Name = "";
				SessionFacade.SaveOrUpdateCompany(c);
			}
			
			c = new Company();
			c.Name = "Company A";
			SessionFacade.SaveOrUpdateCompany(c);
			
			if (SessionFacade.ReadUserByNameAndPassword("admin", "root") == null) {
				User u = new User();
				u.Name = "admin";
				u.Password = "root";
				SessionFacade.SaveOrUpdateUser(u);
			}
			
			Department d = new Department();
			d.Name = "";
			d.Inactive = false;
			SessionFacade.SaveOrUpdateDepartment(d);
			
			Position p = new Position();
			p.Name = "";
			p.Inactive = false;
			SessionFacade.SaveOrUpdatePosition(p);
			
			EmployeeType t = new EmployeeType();
			t.Name = "";
			t.Inactive = false;
			SessionFacade.SaveOrUpdateEmployeeType(t);
			
			Shift s = new Shift();
			s.Notes = "";
			s.RegularHours = 0;
			s.GracePeriod = 0;
			s.Inactive = false;
			SessionFacade.SaveOrUpdateShift(s);
			
			Employee e = new Employee();
			e.Name = new Name("", "", "", "");
			e.Gender = 1;
			e.Department = d;
			e.Position = p;
			SessionFacade.SaveOrUpdateEmployee(e);
			
			Timesheet tm = new Timesheet();
			tm.Employee = e;
			tm.Date = new DateTime(2009, 9, 2, 8, 0, 0);
			tm.In = true;
			SessionFacade.SaveOrUpdateTimesheet(tm);
			
			tm = new Timesheet();
			tm.Employee = e;
			tm.Date = new DateTime(2009, 9, 2, 17, 0, 0);
			tm.In = false;
			SessionFacade.SaveOrUpdateTimesheet(tm);
			
			PayrollCode pc = new PayrollCode();
			pc.Code = "20090915";
			pc.StartDate = new DateTime(2009, 8, 26);
			pc.EndDate = new DateTime(2009, 9, 10);
			pc.Inactive = false;
			SessionFacade.SaveOrUpdatePayrollCode(pc);
		}
		
		[Test]
		public void TestEtcetera()
		{
			ToDo t = new ToDo();
			t.Note = "";
			t.RemindOn = DateTime.Now;
			t.Done = false;
			t.Inactive = false;
			SessionFacade.SaveOrUpdateToDo(t);
			
			SSSPremium p = new SSSPremium();
			p.Code = "";
			p.RangeFrom = 0;
			p.RangeTo = 0;
			p.ER = 0;
			p.EE = 0;
			p.EC = 0;
			p.Contribution = 0;
			p.Inactive = false;
			SessionFacade.SaveOrUpdateSSSPremium(p);
			
			foreach (SSSPremium dummy in SessionFacade.FindAllSSSPremiums()) {
				Console.WriteLine(dummy.Code);
			}
			
			PhilhealthPremium q = new PhilhealthPremium();
			q.Code = "";
			q.Inactive = false;
			SessionFacade.SaveOrUpdatePhilhealthPremium(q);
			
			PagIbigPremium r = new PagIbigPremium();
			r.Code = "";
			r.Inactive = false;
			SessionFacade.SaveOrUpdatePagIbigPremium(r);
		}
	}
}
